import React from 'react';
import { Empty, Table, Tag } from 'antd';
import FormContainer from './FormContainer';

/**
 * 员工档案 - 资产信息 - 固定资产
 */
const AssetsSection = ({ formData }) => {
    const columns = [
        {
            title: '资产名称',
            dataIndex: 'assetName',
            key: 'assetName'
        },
        {
            title: '资产类型',
            dataIndex: 'assetType',
            key: 'assetType',
            render: text => ['固定资产', '消耗品'][text]
        },
        {
            title: '资产编号',
            dataIndex: 'assetNumber',
            key: 'assetNumber'
        },
        {
            title: '领取时间',
            dataIndex: 'createTime',
            key: 'createTime'
        },
        {
            title: '分配人',
            dataIndex: 'distributionEntryPersonnelName',
            key: 'distributionEntryPersonnelName'
        },
        {
            title: '状态',
            dataIndex: 'accepted',
            key: 'accepted',
            render: text => (text === 1 ? <Tag color="green">已接收</Tag> : <Tag>未接收</Tag>)
        }
    ];

    // render
    return (
        <FormContainer title="固定资产" hasEditAuth={false}>
            {() =>
                formData?.length ? (
                    <Table
                        columns={columns}
                        dataSource={formData}
                        rowKey="id"
                        scroll={{ y: 1080 }}
                        pagination={false}
                    />
                ) : (
                    <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                )
            }
        </FormContainer>
    );
};

export default AssetsSection;
